<template>
    <div>
        <h1>3---小说展示页面</h1>
        <p v-for="(fiction,index) in fiction_li" :key="index">

        小说名称：<a :href="'/#/xq?id=' +fiction.id">{{fiction.name}}</a>
        小说图片：<img :src="'http://127.0.0.1:8000/' + fiction.img" alt="">
        <button @click="xszs(fiction.id)">删除</button>

        </p>
        
        <p ></p>
    </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
        return {
            fiction_li:[]

        }
    }, 
    methods: {
        xszs(id){
            axios({
                url:'http://127.0.0.1:8000/app01/fiction/?id=' + id,
                method:'delete'
            }).then(res=>{
                console.log(res.data)
                location.reload()

            })
        }

    },
    created() {
        axios({
            url:'http://127.0.0.1:8000/app01/fiction/',
            method:'get'
        }).then(res=>{
            console.log(res.data)
            this.fiction_li = res.data
        })

    }
}
</script>

<style scoped>

</style>
